﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Mobile/Masters/MobileSite.master" AutoEventWireup="true" CodeFile="Product.aspx.cs" Inherits="Mobile_Product" %>

<%@ Register src="~/Mobile/Parts/SearchBarMobile.ascx" tagname="SearchBarMobile" tagprefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Title" Runat="Server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="Head" Runat="Server">
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeadBody" Runat="Server">
<header>
	<div class="sortable">
		<ul>
			<li><a href="Default.aspx"><strong>E-Document</strong></a></li>
			<li><a href="Login.aspx"><strong>Tài khoản</strong></a></li>
			<li><a href="Default.aspx"><strong>Danh mục</strong></a></li>
		</ul>
		<div class="edge"></div>
		<div class="edge right"></div>
	</div>
</header>

<%
    int id = 0;
    try
    {
        id = int.Parse(Request.QueryString["ID"]);
    }
    catch { }
    
    NhaKinhDoanhDataContext db = new NhaKinhDoanhDataContext();

    var query = (from sp in db.TaiLieus
                where sp.ProductID == id
                select sp).Take(1);
    if (query.Count<TaiLieu>() == 0)
    {
        query = (from sp in db.TaiLieus
                 select sp).Take(1);
    }

    TaiLieu tl = query.Single<TaiLieu>();

    Session["TaiLieu"] = tl;
    
    string strName = tl.ProductName;
    if (strName.Length > 20)
    {
        strName = strName.Substring(0, 20) + " ..";
    }
%>

<header>
	<a class="goback" href="javascript: history.go(-1)"><strong>Back</strong></a>

	<h1><%= strName %></h1>
	<a href="CartIphone.aspx" class="cartbutton">
        <img alt="Cart" src="Images/cart2.png" style="float:right;padding-top:5px;" title=""/> 
    </a>
</header>

    <div class="clear" style="margin-top:-20px"></div>

    <uc1:SearchBarMobile ID="SearchBarMobile1" runat="server" />
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="MainContent" Runat="Server">
<%    
    TaiLieu tl = (TaiLieu)Session["TaiLieu"];    
%>

    <div id="bookinfo">
	    <img class="cover" alt="<%= tl.ProductName %>" src="<%= tl.ProductPhotoURL %>" title="<%= tl.ProductName %>"/>
<div class="book-details">
	<h1><%= tl.ProductName %></h1>
    <h2>&nbsp</h2>
	<%--<h2> 
        <a href="Category.aspx?CateID=<%= tl.CatID %>"><%= tl.DanhMuc.CatName %></a>
    </h2>--%>
	<div class="publisher">
        <a href="Category.aspx?CateID=<%= tl.CatID %>"><%= tl.DanhMuc.CatName %></a>
    </div>
	<div class="price">
	    <%= ((double)tl.ProductPrice).ToString() + " USD" %>
	    <a class="button" href="CartIphone.aspx"><b>Mua ngay</b></a>						
	</div>
</div>
	</div>

	<div id="bookdesc" style="text-align:justify;">
		<%= tl.ProductDescription %>
	</div>
		
	<div id="similarbooks">
		<h3>Cùng danh mục</h3>
		<div id="storelisting">
			<ul id="booklisting">

<%
    NhaKinhDoanhDataContext db = new NhaKinhDoanhDataContext();

    var query = (from sp in db.TaiLieus
                 where sp.CatID.Trim().Equals(tl.CatID.Trim())
                 select sp).Take(2);
    if (query.Count<TaiLieu>() == 0)
    {
        query = (from sp in db.TaiLieus
                 select sp).Take(2);
    }

    foreach (TaiLieu t in query)
    {
%>
				<li class="details">
                    <a href="Product.aspx?ID=<%= t.ProductID %>">
                        <img alt="<%= t.ProductName %>" src="<%= tl.ProductPhotoURL %>" title="<%= t.ProductName %>"/>
                        <span><%= t.ProductName %></span>
                    </a>
                </li>
<% 
    }
%>
                <%--<li class="details">
                    <a href="#">
                        <img alt="The Girl Who Played with Fire" src="Images/Products/000606216-min-1.jpg" title=""/>
                        <span>The Girl Who Played with Fire</span>
                    </a>
                </li>--%>

			</ul>
		</div>
	</div>
</asp:Content>